GEO 330 Exercise #2

Evaluate Trends in Divvy Bikesharing Trips, 2013-2023

Author

C. Scott Smith, PhD AICP (Instructor)

Published

January 24, 2024

Purpose

This project examines trends in Divvy bike sharing ridership over time (i.e., between 2013 and 2023) and by community area within the city of Chicago. Students will develop custom R scripts to explore how ridership varies across communities with respect to demographic and socioeconomic characteristics. The exercise uses custom summary tables produced from a comprehensive dataset of over 41 million Divvy bike trips logged between the official launch of the program on June 27, 2013 through 2023.

Required (and optional) reading

Read the National Association of City Transportation Officials (NACTO) Half a Billion Trips on Shared Micromobility Since 2010 report which summarizes changes in municipal bikeshare systems over the past decade along with emerging trends in micromobility programs.

Also, consider reading Dimensions of Divvy: Exploring the performance of bikesharing in Chicago in a period of growth and expansion. This study, published in 2018, characterizes the three initial phases of Chicago’s Divvy system beginning with its initial rollout in 2013 through its first and second expansions, in 2015 and 2016, respectively, paying special attention to service and performance gaps.

Step 1. Create a new R project

In RStudio, create a project within a new directory (e.g., SUD330/exercise_03) on your computer. The new directory will serve as your project working directory where you will store files related to this exercise. Create the following folders within the new directory–“data”, “images” and “scripts”–to store exercise-specific files.

Install R and RStudio

R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS. You can download and install R via the R Archive Network web pages.

RStudio is an integrated development environment (IDE) for R. It has a set of tools built to help R users be more productive with R (and other languages including Python)). It includes a console, syntax-highlighting editor that supports direct code execution. It also features tools for plotting, viewing history, debugging and managing your workspace. You can download RStudio via the Posit website.

Step 2. Create a new R script

In the “Files” tab of your RStudio interface (conventionally located on the bottom right panel), navigate to the “scripts” folder in your working directory. Create a new R script in the “scripts” directory and assign it an intuitive name (e.g., “Exercise_02.R”). You will use this script to manage and execute all code for this exercise.

Step 3. Install and activate R packages

Students will use several R packages to complete the exercise, including “dplyr” and “tidyverse” for data formatting and wrangling, “sf” (simple feature) for importing, transforming geographic data, “plotly” for creating interactive figures, and “leaflet” for producing interactive maps. Copy and paste the following code to activate the associated packages in R. It may also be necessary to install the packages prior to activating. If so, uncomment the install.packages command.

# install.packages(c("dplyr", "tidyverse", "sf", "leaflet", "plotly"))

library(dplyr) # data wrangling with pipe syntax
library(tidyverse) # data wrangling
library(sf) # simple features geometry data
library(plotly) # interactive plots
library(leaflet) # interactive maps

options(scipen=999, digits = 2) # format output for data tables

Step 4. Download presentation template and process data

As with previous exercises, you are asked to combine and submit all materials into a single presentation. The basic template for this exercise can be downloaded via this link to the PowerPoint slides on the course GitHub.

This exercise makes use of data from a variety of sources. Custom summary tables of Divvy trip origins and destinations by date and community area between 2013 and 2022 were adapted from raw trip information made available via the City of Chicago’s data portal and Divvy bikeshare system data web pages. Frequencies of trips will be mapped by city of Chicago community area boundaries imported directly from the city of Chicago’s data portal. Lastly, variations in trips will be evaluated with respect to neighborhood demographic socioeconomic measures downloaded from the Chicago Health Atlas. Copy and paste the code below to import the necessary data from the course GitHub and the city of Chicago’s data portal.

Chicago Health Atlas

The Chicago Health Atlas publishes data on hundreds of sociodemographic and public health indicators for communities throughout the city. The website allows for searching and exploring various metrics via maps, charts and tables. Indicator data can also be downloaded by community area, census tract and zip code. Refer to the Atlas’ how to use page for more information.

# import Divvy summary trip data frames from course GitHub
load(url("https://github.com/justenvirons/pedagogy/raw/main/docs/exercises_transportation/data/divvy_trips_summary_tables.RData"))

# import City of Chicago community areas (N=77) GEOJSON from Chicago data portal and transform to geographic projection for mapping (epsg:4326)
community_areas <- st_read("https://data.cityofchicago.org/api/geospatial/cauq-8yn6?method=export&format=GeoJSON") %>% 
  st_transform(4326) %>%
  mutate(`comarea_id` = as.numeric(area_numbe),
         comarea_name = str_to_title(community)) %>%
  select(comarea_id, comarea_name)

# import socioeconomic characteristics by community area (adapted from the Chicago Health Atlas) from the course GitHub
ses_attributes <- read_csv("https://github.com/justenvirons/pedagogy/raw/main/docs/exercises_transportation/data/chicago_health_atlas_indicators.csv")

# join community areas with socioeconomic status (SES) attributes to create custom dataset
# add one to rank values to adjust range from 0-76 to 1-77
# create and label quintile (ntile) categories for each SES measure 
fx_ntile <- function(x, na.rm=TRUE)(ntile(x,5))
fx_ntile_label <- function(x, na.rm=TRUE)(case_when(x==1 ~ "Lowest",
                                         x==2 ~ "Low",
                                         x==3 ~ "Moderate",
                                         x==4 ~ "High",
                                         x==5 ~ "Highest"))

community_areas_ses <- community_areas %>%
  left_join(ses_attributes %>% select(-Name), by="comarea_id") %>%
  mutate_at(vars(svi_2020:poverty_2021), list(ntile = fx_ntile)) %>%
  mutate_at(vars(svi_2020_ntile:poverty_2021_ntile), list(label = fx_ntile_label)) %>%
  select(-ends_with("ntile"))
Preparation of the 2013-2023 41M Divvy trips dataset

The summary tables used for this exercise was assembled using multiple datasets. Code for creating the comprehensive trip dataset is available on the course GitHub.

Step 6. Explore total and average trips by community area

In this step we examine variations in Divvy trip patterns across the city by community area (N=77). Figure 4 below shows the distribution of total Divvy trips between 2013 and 2023 across the city. Hover over the community area boundaries to observe their respective total (cumulative) and average daily riderships over the past decade. Daily ridership per 10,000 residents (i.e., ridership standardized by the community area population) is also indicated.

In slide 4 of your presentation, note any patterns and/or variations you see in total ridership by community area. What factors do you feel explain differences in total and daily ridership? Support your findings by referencing statistics from the figure.

Figure 4: Total Divvy Trips by Community Area (Quintile Categorization)